Next | Prev | Up | Top | Contents | Index

Designing With the Frame Scheduler

To use the Frame Scheduler, you approach the design of your real-time program in the following steps.

  1. Partition the program into activities, where each activity is an independent piece of work that can be done without interruption.

    For example, in a simple vehicle simulator, activities might include "poll the joystick," "update the positions of moving objects," "cull the set of visible objects," and so forth.

  2. Decide the relationships among the activities:

  3. Estimate the worst-case time required to execute each activity. Some activities may need more than one minor frame interval (the Frame Scheduler allows for this).

  4. Schedule the activities: If all are executed sequentially, will they complete in one major frame? If not, choose activities that can execute concurrently on two or more CPUs, and estimate again. You may have to change the design in order to get greater concurrency.
When the design is complete, implement each activity as an independent process that communicates with the others using shared memory, semaphores, and locks (see "Interprocess Communication").

When the real-time activities can be handled in a single CPU, the master process that initiates the program contains these steps:

  1. Open, create, and initialize all the shared files and memory resources.

  2. Initiate a Frame Scheduler (a single library call).

  3. Initiate each activity as a process using sproc() or fork().

    Each process initializes itself and then waits at a barrier (see "Barriers").

  4. Enqueue each activity process to the Frame Scheduler that will dispatch it (another library call).

    The master process specifies the process ID and the minor frame or frames in which the process should run, and a scheduling discipline.

  5. Join the barrier where the activity processes are waiting.

    When all processes are ready to proceed, all are released.

  6. Start the Frame Scheduler going (a library call).

  7. Wait for a signal indicating it is time to shut down.

  8. Terminate the Frame Schedulers.
A Frame Scheduler seizes its assigned CPU, isolates it, and takes over process scheduling on it. It waits for all enqueued processes to initialize themselves and to execute a library call to "join" the scheduler. Then it begins dispatching the processes in the specified sequence during each frame interval. It monitors errors, such as a process that fails to complete its work within its frame, and takes a specified action when an error occurs. Typically the error action is to send a signal to the master process. The master process can interrogate the Frame Scheduler, and stop it or restart it.

The Frame Scheduler is discussed in more detail in Chapter 7, "Using the Frame Scheduler". Sample programs that illustrate the Frame Scheduler are described under "Frame Scheduler Examples".


Next | Prev | Up | Top | Contents | Index